package com.kadron.comment;

import java.util.Date;

import com.kadron.common.KUtil;
import com.kadron.datamodel.KModel;
import com.kadron.entity.KItemImage;
import com.kadron.enumeration.CommentType;
import com.kadron.paging.KRow;

public class KCommentModel implements KModel, KRow {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7642605358448921205L;
	
	private boolean marked;
	private long commentId;
	private Long userId;
	private String comment;
	private String thumb;
	private String name;
	private Date created;
	private boolean approved;
	private Long itemId;
	private CommentType type;
	private KItemImage itemImg;
	private String ipAddress;
	
	public KCommentModel(long commentId, Long userId, String comment,
			String thumb, String name, Date created, boolean approved) {
		super();
		this.commentId = commentId;
		this.userId = userId;
		this.comment = comment;
		this.thumb = thumb;
		this.name = name;
		this.created = created;
		this.approved = approved;
	}

	public boolean isMarked() {
		return marked;
	}

	public void setMarked(boolean marked) {
		this.marked = marked;
	}
	
	public String getComment() {
		return comment;
	}
	
	@Override
	public long getId() {
		return commentId;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (commentId ^ (commentId >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		KCommentModel other = (KCommentModel) obj;
		if (commentId != other.commentId)
			return false;
		return true;
	}

	public String getThumb() {
		return thumb;
	}

	public void setThumb(String thumb) {
		this.thumb = thumb;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public boolean isApproved() {
		return approved;
	}

	public void setApproved(boolean approved) {
		this.approved = approved;
	}

	public Long getItemId() {
		return itemId;
	}

	public void setItemId(Long itemId) {
		this.itemId = itemId;
	}

	public CommentType getType() {
		return type;
	}

	public void setType(CommentType type) {
		this.type = type;
	}

	public KItemImage getItemImg() {
		return itemImg;
	}

	public void setItemImg(KItemImage itemImg) {
		this.itemImg = itemImg;
	}

	public String getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	public boolean isUserAvb() {
		return userId != null && userId > 0;
	}
	
	public boolean isThumbAvb() {
		return !KUtil.isEmpty(thumb);
	}
}
